package com.gdufe.firesafe.model.enums;

/**
 * 设备类型枚举（1-灭火器，2-烟雾探测器）
 */
public enum DeviceTypeEnum {
    FIRE_EXTINGUISHER(1, "灭火器"),
    SMOKE_DETECTOR(2, "烟雾探测器");

    private final Integer code;
    private final String description;
    DeviceTypeEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }
    public Integer getCode() {
        return code;
    }
    public String getDescription() {
        return description;
    }

    public static DeviceTypeEnum getEnumByCode(Integer code) {
        for (DeviceTypeEnum deviceTypeEnum : DeviceTypeEnum.values()) {
            if (deviceTypeEnum.getCode().equals(code)) {
                return deviceTypeEnum;
            }
        }
        return null;
    }
    public static DeviceTypeEnum getEnumByDesc(String description) {
        for (DeviceTypeEnum deviceTypeEnum : DeviceTypeEnum.values()) {
            if (deviceTypeEnum.getDescription().equals(description)) {
                return deviceTypeEnum;
            }
        }
        return null;
    }
}
